home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 March
/
CMCD0305.ISO
/
Software
/
Shareware
/
Utilitare
/
emu
/
Emu8086_Setup_307c.exe
/
{app}
/
Samples
/
palindrome.asm
< prev
next >
Wrap
Assembly Source File
|
2002-11-28
|
581b
|
43 lines
; This sample checks if string
; is a palindrome.
#make_COM#
ORG 100h
jmp start
s DB 'aaabbbaaa'
s_size DW 9
start:
LEA DI, s
MOV SI, DI
ADD SI, s_size
DEC SI ; point to last char!
MOV CX, s_size
SHR CX, 1 ; divide by 2!
next_char:
MOV AL, [DI]
MOV BL, [SI]
CMP AL, BL
JNE not_Palindrome
INC DI
DEC SI
LOOP next_char
is_Palindrome:
; Set AX to 0FFFFh - the string is "Palindrome!"
MOV AX, 0FFFFh
JMP stop
not_Palindrome:
; Set AX to 0ABCDh - the string is "Not Palindrome!"
MOV AX, 0ABCDh
stop:
RET